import { FormGroup, FormBuilder } from '@angular/forms'
import { Terminal, TerminalNewRequest } from '@shared/interfaces/terminal'
import { TerminalStoreService } from './terminal-store.service'

export abstract class TerminalNewBaseClass {
  terminal: TerminalNewRequest

  validateForm: FormGroup

  constructor(
    public fb: FormBuilder,
    public terminalStore: TerminalStoreService,
  ) {
    this.validateForm = this.fb.group({})
    this.initData()
  }

  initData(): void {
    this.terminalStore
      .value$
      .subscribe(terminal => {
        this.terminal = terminal
      })
  }

  checkValid(): boolean {
    this.pushDataToStore()
    return true
  }

  abstract pushDataToStore(): void
}
